package cn.edu.njnu.service;

import cn.edu.njnu.mapper.IllustrationMapper;
import cn.edu.njnu.pojo.Illustration;
import cn.edu.njnu.pojo.Result;
import cn.edu.njnu.pojo.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IllustrationService {
    @Autowired
    private IllustrationMapper illustrationMapper;
    public Result getIllustration(String keywords) {
        if (keywords.isEmpty())
            return ResultFactory.buildFailResult("关键词不能为空");
        List<Illustration> illustrations = illustrationMapper.getIllustrationByEntity(keywords);
        if (illustrations.isEmpty())
            return ResultFactory.buildFailResult("未找到相关插图");
        return ResultFactory.buildSuccessResult("获取插图成功", illustrations);
    }
}
